package com.derbysoft.lowcostadapter.dswitch2.service.helper;

import com.derbysoft.lowcostadapter.commons.exception.SystemException;
import com.derbysoft.remote.dswitch.generic.constants.UniqueIDType;
import com.derbysoft.remote.dswitch.hotel.dto.HotelReservationIDDTO;

import java.util.List;

public abstract class ResIDHelper {
    public static String find(List<HotelReservationIDDTO> hotelReservationIDs, UniqueIDType uniqueIDType) {
        for (HotelReservationIDDTO hotelReservationID : hotelReservationIDs) {
            if (uniqueIDType == hotelReservationID.getResIDType()) {
                return hotelReservationID.getResIDValue();
            }
        }
        throw new SystemException(String.format("Reservation ID [%s] not found", uniqueIDType.getCode()));
    }

    public static HotelReservationIDDTO ersp(String value) {
        return new HotelReservationIDDTO(UniqueIDType.ERSP, value);
    }

    public static HotelReservationIDDTO hotel(String value) {
        return new HotelReservationIDDTO(UniqueIDType.HOTEL, value);
    }
}
